#import ebcdic
import sys, os
infile = open("centrelmessaging.queue", "rb")


done = False
i = 0
while not done:
     data = infile.read(999999999)
     #if len(data) < 32768:
     done = True
     msgslist = str(data).split("#@#@#")
     for msg in msgslist:
          #print msg
          pos = msg.find("<soapenv:Envelope")
          #print pos
          if msg.find("</soapenv:Envelope>"):
              open("outmsg" + str(i) + '.txt', "w").write(msg[pos:])
	  #open("outmsg", "w").write(msg)
          i =  i  + 1
     
